package com.rd.student.jike.class2.lihongming.week724_730.Day725;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

/**
 * @Auther:Heinrich
 * @Date:2023/7/25-07-25-11:23
 * @Description:c230725
 * @version:1.0
 */
public class ClassTest01 {
    public static void main(String[] args) {
        File file = new File(System.getProperty("user.dir"));
        System.out.println(file);
        File fileDir1 = new File(file+"/"+"f1");
        Boolean result1 =  fileDir1.mkdir();
        File fileDir2 = new File(file+"/"+"f2");
        Boolean result2  = new File(file+"/"+"f2").mkdir();
        File file1 = new File(fileDir1.getPath()+"/"+"t1.txt");
        File file2 = new File(fileDir1.getPath()+"/"+"t2.txt");
        File file3 = new File(file+"/"+"f2"+"/"+"t3.txt");
        File file4 = new File(file+"/"+"f2"+"/"+"t4.txt");
        try {
            if(!file1.exists()){
            Boolean result3  =file1.createNewFile();
                System.out.println(file1.getPath()+" 创建成功！");
            }else{
                System.out.println(file1.getPath()+" 创建失败！");
            }
            if(!file2.exists()){
                Boolean result4  =file2.createNewFile();
                System.out.println(file2.getPath()+" 创建成功！");
            }else{
                System.out.println(file2.getPath()+" 创建失败！");
            }
            if(!file3.exists()){
                Boolean result5  =file3.createNewFile();
                System.out.println(file3.getPath()+" 创建成功！");
            }else{
                System.out.println(file3.getPath()+" 创建失败！");
            }
            if(!file4.exists()){
                Boolean result6  =file4.createNewFile();
                System.out.println(file4.getPath()+" 创建成功！");
            }else{
                System.out.println(file4.getPath()+" 创建失败！");
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (file4.exists()) {
            Boolean result7 = file4.delete();
            System.out.println(file4.getPath()+" 删除成功！");
        }
        if (file3.exists()) {
            Boolean result8 = file3.renameTo(file4);
            System.out.println(file3.getPath()+" 修改成功！");
        }
        System.out.println(Arrays.toString(fileDir1.listFiles()));
        System.out.println(Arrays.toString(fileDir2.listFiles()));
        //System.out.println(Arrays.toString(fileDir1.getParentFile().listFiles()));

    }
}
